# models.py
from django.db import models


class Menu(models.Model):
    title = models.CharField(
        max_length=50,
        verbose_name='菜单名称',
    )
    indexPath = models.CharField(
        max_length=100,
        verbose_name='路由路径',
    )
    icon = models.CharField(
        max_length=50,
        verbose_name='图标类名',
    )
    parent = models.ForeignKey(
        to='self',
        null=True,
        blank=True,
        related_name='children',
        on_delete=models.CASCADE
    )
    order = models.IntegerField(
        default=0,
        verbose_name='排序',
    )

    class Meta:
        ordering = ['order']

    def __str__(self):
        return self.title
